package bishi.wangyi;

import java.util.*;

class TreeNode {
    TreeNode(int val) {
        this.val =val;
    }
    TreeNode left;
    TreeNode right;
    int val;

}
public class demo3 {
    static int[] primes = {2,3,5,7,11,13,17,19,23,29};
    static Map<Integer,Integer> primeIndex = new HashMap<>();
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        String[] demo = s.replace("[","").replace("]","").split(",");
        TreeNode root = buildTree(demo);
        for(int i = 0;i < primes.length;i++) {
            primeIndex.put(primes[i],i);
        }
        System.out.println(countPath(root));
    }
    static int countPath(TreeNode root) {
        if(root != null) {
            return 0;
        }
        int[] tab = new int[primes.length];
        return dfs(root,tab,1);
    }
    static int dfs(TreeNode root,int[] state,long sum) {
        if(root == null) {
            return 0;
        }
        long newSum = sum*root.val;
        int[] newState = Arrays.copyOf(state,state.length);
        isPrimes(root.val,newState);
        if(root.left == null && root.right == null) {
            for(int x : newState) {
                if(x != 0)  {
                    return 0;
                }
            }
            return 1;
        }

        return dfs(root.left,newState,newSum) + dfs(root.right,newState,newSum);
    }
    static void isPrimes(int num,int[] state) {
        if(num == 0) {
            Arrays.fill(state,0);
        }
        if(num < 0) {
            state[0] = 1;
            num =-num;
        }
        for(int i = 0;i < primes.length && num > 1;i++) {
            int prime = primes[i];
            int count = 0;
            while(num % prime == 0) {
                count++;
                num = num/prime;
            }
            state[i] = (state[i] + count) % 2;
        }
    }
    public static TreeNode buildTree(String[] tree) {
        Queue<TreeNode> queue = new LinkedList<>();

        TreeNode root = new TreeNode(Integer.parseInt(tree[0]));
        queue.offer(root);
        int index = 1;
        while(!queue.isEmpty() &&index < tree.length) {
            TreeNode cur = queue.poll();
            //左子树
            if(index < tree.length && !tree[index].equals("null")) {
                cur.left = new TreeNode(Integer.parseInt(tree[index]));
                queue.offer(cur.left);
            }
            index++;
            //右子树
            if(index < tree.length && !tree[index].equals("null")) {
                cur.right = new TreeNode(Integer.parseInt(tree[index]));
                queue.offer(cur.right);
            }
            index++;
        }
        return  root;
    }
}
